HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: /var/www/kevin-demo/wp-content/plugins/grocerslist/includes/Support/Config.php
<?php
namespace GrocersList\Support;

class Config {
    public static function getApiBaseDomain(): string {
        if (!defined('GROCERSLIST_API_BASE_DOMAIN')) {
            throw new \RuntimeException('GROCERSLIST_API_BASE_DOMAIN is not defined');
        }
        return GROCERSLIST_API_BASE_DOMAIN;
    }

    public static function getLinkstaSubdomain(): string {
        if (!defined('GROCERSLIST_LINKSTA_SUBDOMAIN')) {
            throw new \RuntimeException('GROCERSLIST_LINKSTA_SUBDOMAIN is not defined');
        }
        return GROCERSLIST_LINKSTA_SUBDOMAIN;
    }

    public static function getExternalJsUrl(): string {
        if (!defined('GROCERSLIST_EXTERNAL_JS_URL')) {
            throw new \RuntimeException('GROCERSLIST_EXTERNAL_JS_URL is not defined');
        }
        return GROCERSLIST_EXTERNAL_JS_URL;
    }

    /**
     * Get plugin version using WordPress's built-in versioning system
     * Falls back to the constant if plugin data is not available
     */
    public static function getPluginVersion(): string {
        static $version = null;
        
        if ($version === null) {
            if (!function_exists('get_plugin_data')) {
                require_once ABSPATH . 'wp-admin/includes/plugin.php';
            }
            
            if (defined('GROCERS_LIST_PLUGIN_FILE') && file_exists(GROCERS_LIST_PLUGIN_FILE)) {
                $plugin_data = get_plugin_data(GROCERS_LIST_PLUGIN_FILE);
                $version = $plugin_data['Version'] ?? GROCERS_LIST_VERSION;
            } else {
                $version = GROCERS_LIST_VERSION;
            }
        }
        
        return $version;
    }

    /**
     * Get just the domain/host for the current WordPress blog
     * 
     * @return string Just the domain (e.g., example.com or subdomain.example.com)
     */
    public static function getBlogDomain(): string {
       $url = get_bloginfo('url');
       $parsed = parse_url($url);
       return $parsed['host'] ?? '';
    }

}